/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on Oct 21, 2009, 12:18:44 PM
 */

package viewer.main;

import java.util.logging.Level;
import java.util.logging.Logger;
import viewer.main.tree.TraceTree;
import viewer.main.tree.TreeDisplay;
import viewer.main.tree.Tree;
import viewer.main.tree.SaveJTree;
import builder.tree.CompressTree;
import data.processing.Controller;
import java.awt.Dimension;
import java.awt.Graphics;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;
import log.messages.LOG;
import sequence.alignment.NeedlemanWunsch;
import utils.SwingWorker;
import viewer.main.tree.AlignmentTree;
import viewer.main.tree.ColapsedTrees;


/**
 *
 * @author Luciana
 */
public class Main extends javax.swing.JFrame implements TreeSelectionListener{
    private String strCurrentPath="";
    private String strCurrentPathSelected="";
    private String strCurrentFilePath="";
    private JTree jtree=null;
    private JTree jtreeGSP=null;
    private DefaultMutableTreeNode sequenceTree = null;
    private builder.tree.Tree tree = null;
    private String requiredMethod = "";
    private int size = 0;
    private String system = "";
    private boolean changed = true;
    private Controller controller;
    private boolean align = false;
    private File rootSequence = null;

    /** Creates new form Main */
    public Main() {
        this.setTitle("Summarization");
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup = new javax.swing.ButtonGroup();
        jPnlWeast = new javax.swing.JPanel();
        jPnlRepository = new javax.swing.JPanel();
        jScrollPaneTree = new javax.swing.JScrollPane();
        jPanelMeadle = new javax.swing.JPanel();
        jPanel = new javax.swing.JPanel();
        jPanelRepository = new javax.swing.JPanel();
        txtFPath = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jButton = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelCompressors = new javax.swing.JPanel();
        jPanelNorthCompressor = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jComboBoxStep1 = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jComboBoxStep2 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jComboBoxStep3 = new javax.swing.JComboBox();
        this.jComboBoxStep3.setVisible(false);
        jLabel15 = new javax.swing.JLabel();
        this.jLabel15.setVisible(false);
        txtMetrics = new javax.swing.JTextField();
        this.txtMetrics.setVisible(false);
        jLabel16 = new javax.swing.JLabel();
        txtFieldSelectedTraceCompressor = new javax.swing.JTextField();
        btnExecutePreProcessing = new javax.swing.JButton();
        btnDeleteDirectories = new javax.swing.JButton();
        jPanelFeatures = new javax.swing.JPanel();
        jPanelFeature_North = new javax.swing.JPanel();
        jTxtFeature = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jPanelFeature_South = new javax.swing.JPanel();
        jButtonFeature = new javax.swing.JButton();
        jPanelDataMining = new javax.swing.JPanel();
        jPanelEast = new javax.swing.JPanel();
        btnBuildTree = new javax.swing.JButton();
        jBtnSaveSequence = new javax.swing.JButton();
        jPanelNorth = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        txtFieldSelectedTrace = new javax.swing.JTextField();
        txtFieldSuporte = new javax.swing.JTextField();
        txtFSize = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jPanelCenter = new javax.swing.JPanel();
        radioEqual = new javax.swing.JRadioButton();
        radioPrefix = new javax.swing.JRadioButton();
        radioSuffix = new javax.swing.JRadioButton();
        radioBtnA_C = new javax.swing.JRadioButton();
        radioExtremity = new javax.swing.JRadioButton();
        jButtonCarryTree = new javax.swing.JButton();
        jPanelRecoveryStructure = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        txFile = new javax.swing.JTextField();
        txtFNroClusters = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtFNroNivel = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtFNroCoberturaChamadas = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        btnGetStructure = new javax.swing.JButton();
        jCheckBoxCompressor = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jTxtSequence1 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTxtSequence2 = new javax.swing.JTextField();
        btnAlign = new javax.swing.JButton();
        jCheckBoxSeq1 = new javax.swing.JCheckBox();
        jCheckBoxSeq2 = new javax.swing.JCheckBox();
        btnViewAlignment = new javax.swing.JButton();
        jBtnColapsedTree = new javax.swing.JButton();
        jPanelText = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneMessages = new javax.swing.JTextPane();
        jPanelProgress = new javax.swing.JPanel();
        labelProgressTask = new javax.swing.JLabel();
        jPnlEast = new javax.swing.JPanel();
        jPanelGSP = new javax.swing.JPanel();
        jScrollPaneGSP = new javax.swing.JScrollPane();

        buttonGroup.add(radioEqual);
        buttonGroup.add(radioPrefix);
        buttonGroup.add(radioSuffix);
        buttonGroup.add(radioExtremity);
        buttonGroup.add(radioBtnA_C);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(900, 300));
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        jPnlWeast.setBackground(new java.awt.Color(255, 255, 255));
        jPnlWeast.setMinimumSize(new java.awt.Dimension(200, 509));
        jPnlWeast.setPreferredSize(new java.awt.Dimension(200, 509));

        jPnlRepository.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Trace Repository ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Microsoft Sans Serif", 0, 11))); // NOI18N
        jPnlRepository.setMinimumSize(new java.awt.Dimension(200, 418));
        jPnlRepository.setPreferredSize(new java.awt.Dimension(311, 621));

        jScrollPaneTree.setMinimumSize(new java.awt.Dimension(180, 300));
        jScrollPaneTree.setPreferredSize(new java.awt.Dimension(278, 590));

        javax.swing.GroupLayout jPnlRepositoryLayout = new javax.swing.GroupLayout(jPnlRepository);
        jPnlRepository.setLayout(jPnlRepositoryLayout);
        jPnlRepositoryLayout.setHorizontalGroup(
            jPnlRepositoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneTree, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
        );
        jPnlRepositoryLayout.setVerticalGroup(
            jPnlRepositoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneTree, javax.swing.GroupLayout.DEFAULT_SIZE, 591, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPnlWeastLayout = new javax.swing.GroupLayout(jPnlWeast);
        jPnlWeast.setLayout(jPnlWeastLayout);
        jPnlWeastLayout.setHorizontalGroup(
            jPnlWeastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPnlRepository, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
        );
        jPnlWeastLayout.setVerticalGroup(
            jPnlWeastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPnlRepository, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
        );

        getContentPane().add(jPnlWeast);

        jPanelMeadle.setMaximumSize(new java.awt.Dimension(510, 32767));
        jPanelMeadle.setMinimumSize(new java.awt.Dimension(368, 529));
        jPanelMeadle.setPreferredSize(new java.awt.Dimension(510, 609));
        jPanelMeadle.setLayout(new java.awt.CardLayout());

        jPanel.setMaximumSize(new java.awt.Dimension(368, 32767));
        jPanel.setMinimumSize(new java.awt.Dimension(368, 529));
        jPanel.setPreferredSize(new java.awt.Dimension(368, 5529));

        jPanelRepository.setMaximumSize(new java.awt.Dimension(368, 20));
        jPanelRepository.setMinimumSize(new java.awt.Dimension(100, 20));
        jPanelRepository.setPreferredSize(new java.awt.Dimension(368, 20));

        txtFPath.setEditable(false);
        txtFPath.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        jLabel10.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel10.setText("Repository");

        jButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11));
        jButton.setText("...");
        jButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelRepositoryLayout = new javax.swing.GroupLayout(jPanelRepository);
        jPanelRepository.setLayout(jPanelRepositoryLayout);
        jPanelRepositoryLayout.setHorizontalGroup(
            jPanelRepositoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRepositoryLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtFPath, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton)
                .addContainerGap(50, Short.MAX_VALUE))
        );
        jPanelRepositoryLayout.setVerticalGroup(
            jPanelRepositoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRepositoryLayout.createSequentialGroup()
                .addGroup(jPanelRepositoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton)
                    .addComponent(jLabel10))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jCheckBoxCompressor.setVisible(false);
        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jPanelCompressors.setPreferredSize(new java.awt.Dimension(400, 258));
        jPanelCompressors.setLayout(new java.awt.BorderLayout());

        jPanelNorthCompressor.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jPanelNorthCompressor.setPreferredSize(new java.awt.Dimension(494, 256));

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Steps for the data pre-processing ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Microsoft Sans Serif", 0, 11))); // NOI18N
        jPanel9.setFocusable(false);
        jLabel9.setVisible(false);

        jLabel7.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel7.setText("Step 1:");

        jComboBoxStep1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jComboBoxStep1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Compressor", "Minimum Granularity" }));
        jComboBoxStep1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxStep1ItemStateChanged(evt);
            }
        });
        jComboBoxStep1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxStep1ActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel8.setText("Step 2:");

        jComboBoxStep2.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jComboBoxStep2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None", "Minimum Granularity", "Compressor" }));
        jComboBoxStep2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxStep2ItemStateChanged(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel9.setText("Step 3:");

        jComboBoxStep3.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jComboBoxStep3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None", "Compressor", "Minimum Granularity" }));
        jComboBoxStep3.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxStep3ItemStateChanged(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel15.setText("Minimum Granularity :");

        txtMetrics.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxStep1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxStep3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxStep2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(98, 98, 98))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtMetrics, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jComboBoxStep1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jComboBoxStep2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jComboBoxStep3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtMetrics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel16.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel16.setText("Selected Trace");

        txtFieldSelectedTraceCompressor.setEditable(false);
        txtFieldSelectedTraceCompressor.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        btnExecutePreProcessing.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnExecutePreProcessing.setText("Execute");
        btnExecutePreProcessing.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExecutePreProcessingActionPerformed(evt);
            }
        });

        btnDeleteDirectories.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnDeleteDirectories.setText("Delete Selected Trace");
        btnDeleteDirectories.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteDirectoriesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelNorthCompressorLayout = new javax.swing.GroupLayout(jPanelNorthCompressor);
        jPanelNorthCompressor.setLayout(jPanelNorthCompressorLayout);
        jPanelNorthCompressorLayout.setHorizontalGroup(
            jPanelNorthCompressorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelNorthCompressorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelNorthCompressorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnDeleteDirectories)
                    .addGroup(jPanelNorthCompressorLayout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(2, 2, 2)
                        .addComponent(txtFieldSelectedTraceCompressor, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnExecutePreProcessing)))
                .addGap(32, 32, 32))
        );
        jPanelNorthCompressorLayout.setVerticalGroup(
            jPanelNorthCompressorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelNorthCompressorLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanelNorthCompressorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtFieldSelectedTraceCompressor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnExecutePreProcessing))
                .addGap(35, 35, 35)
                .addComponent(btnDeleteDirectories)
                .addGap(29, 29, 29))
        );

        jPanelCompressors.add(jPanelNorthCompressor, java.awt.BorderLayout.PAGE_START);

        jTabbedPane1.addTab("Pre-Processing", jPanelCompressors);

        jPanelFeatures.setLayout(new java.awt.BorderLayout());

        jTxtFeature.setEditable(false);
        jTxtFeature.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        jLabel3.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel3.setText("Trace :");

        javax.swing.GroupLayout jPanelFeature_NorthLayout = new javax.swing.GroupLayout(jPanelFeature_North);
        jPanelFeature_North.setLayout(jPanelFeature_NorthLayout);
        jPanelFeature_NorthLayout.setHorizontalGroup(
            jPanelFeature_NorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFeature_NorthLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTxtFeature, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(34, Short.MAX_VALUE))
        );
        jPanelFeature_NorthLayout.setVerticalGroup(
            jPanelFeature_NorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFeature_NorthLayout.createSequentialGroup()
                .addContainerGap(57, Short.MAX_VALUE)
                .addGroup(jPanelFeature_NorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtFeature, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(23, 23, 23))
        );

        jPanelFeatures.add(jPanelFeature_North, java.awt.BorderLayout.PAGE_START);

        jButtonFeature.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jButtonFeature.setText("Recover Functionalities");
        jButtonFeature.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonFeatureActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelFeature_SouthLayout = new javax.swing.GroupLayout(jPanelFeature_South);
        jPanelFeature_South.setLayout(jPanelFeature_SouthLayout);
        jPanelFeature_SouthLayout.setHorizontalGroup(
            jPanelFeature_SouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFeature_SouthLayout.createSequentialGroup()
                .addContainerGap(349, Short.MAX_VALUE)
                .addComponent(jButtonFeature)
                .addContainerGap())
        );
        jPanelFeature_SouthLayout.setVerticalGroup(
            jPanelFeature_SouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFeature_SouthLayout.createSequentialGroup()
                .addContainerGap(109, Short.MAX_VALUE)
                .addComponent(jButtonFeature)
                .addContainerGap())
        );

        jPanelFeatures.add(jPanelFeature_South, java.awt.BorderLayout.CENTER);

        jTabbedPane1.addTab("Classification by Functionality", jPanelFeatures);

        jPanelDataMining.setPreferredSize(new java.awt.Dimension(400, 258));
        jPanelDataMining.setLayout(new java.awt.BorderLayout());

        btnBuildTree.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnBuildTree.setText("Mining Sequences");
        btnBuildTree.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuildTreeActionPerformed(evt);
            }
        });

        jBtnSaveSequence.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jBtnSaveSequence.setText("Save Recovered Patterns");
        jBtnSaveSequence.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnSaveSequenceActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelEastLayout = new javax.swing.GroupLayout(jPanelEast);
        jPanelEast.setLayout(jPanelEastLayout);
        jPanelEastLayout.setHorizontalGroup(
            jPanelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEastLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jBtnSaveSequence)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnBuildTree)
                .addContainerGap())
        );
        jPanelEastLayout.setVerticalGroup(
            jPanelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEastLayout.createSequentialGroup()
                .addContainerGap(126, Short.MAX_VALUE)
                .addGroup(jPanelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtnSaveSequence)
                    .addComponent(btnBuildTree)))
        );

        jPanelDataMining.add(jPanelEast, java.awt.BorderLayout.LINE_END);

        jLabel17.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel17.setText("Trace/Sequence:");

        jLabel18.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel18.setText("Support:");

        jLabel19.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel19.setText("Motive:");

        txtFieldSelectedTrace.setEditable(false);
        txtFieldSelectedTrace.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        txtFieldSuporte.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        txtFSize.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        jLabel20.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
        jLabel20.setText(" E.g. preffixes: size 1 = a%, size 2 = ab%");

        jLabel21.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11));
        jLabel21.setText("Pattern Support: 5%");

        javax.swing.GroupLayout jPanelNorthLayout = new javax.swing.GroupLayout(jPanelNorth);
        jPanelNorth.setLayout(jPanelNorthLayout);
        jPanelNorthLayout.setHorizontalGroup(
            jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelNorthLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelNorthLayout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFSize, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel20)
                        .addContainerGap())
                    .addGroup(jPanelNorthLayout.createSequentialGroup()
                        .addGroup(jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelNorthLayout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFieldSelectedTrace, javax.swing.GroupLayout.PREFERRED_SIZE, 355, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelNorthLayout.createSequentialGroup()
                                .addComponent(jLabel18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFieldSuporte, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel21)
                                .addGap(77, 77, 77)))
                        .addGap(102, 102, 102))))
        );
        jPanelNorthLayout.setVerticalGroup(
            jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelNorthLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelNorthLayout.createSequentialGroup()
                        .addComponent(txtFieldSelectedTrace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFieldSuporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel21)))
                    .addGroup(jPanelNorthLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel18)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(txtFSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20))
                .addGap(6, 6, 6))
        );

        jPanelDataMining.add(jPanelNorth, java.awt.BorderLayout.PAGE_START);

        radioEqual.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        radioEqual.setText("Equal Methods: abc");

        radioPrefix.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        radioPrefix.setText("Preffix: a%, ab%");

        radioSuffix.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        radioSuffix.setText("Suffix: %c, %bc");

        radioBtnA_C.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        radioBtnA_C.setText("Patterns: a%c");

        radioExtremity.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        radioExtremity.setText("Any Motive");

        jButtonCarryTree.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jButtonCarryTree.setText("Load Saved Pattern");
        jButtonCarryTree.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCarryTreeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelCenterLayout = new javax.swing.GroupLayout(jPanelCenter);
        jPanelCenter.setLayout(jPanelCenterLayout);
        jPanelCenterLayout.setHorizontalGroup(
            jPanelCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCenterLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelCenterLayout.createSequentialGroup()
                        .addGroup(jPanelCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(radioEqual)
                            .addComponent(radioPrefix)
                            .addComponent(radioSuffix)
                            .addComponent(radioBtnA_C)
                            .addComponent(radioExtremity))
                        .addContainerGap(69, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCenterLayout.createSequentialGroup()
                        .addComponent(jButtonCarryTree)
                        .addContainerGap())))
        );
        jPanelCenterLayout.setVerticalGroup(
            jPanelCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCenterLayout.createSequentialGroup()
                .addComponent(radioEqual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(radioPrefix)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(radioSuffix)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(radioBtnA_C)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(radioExtremity)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jButtonCarryTree))
        );

        jPanelDataMining.add(jPanelCenter, java.awt.BorderLayout.CENTER);

        jTabbedPane1.addTab("Sequence Mining", jPanelDataMining);

        jPanelRecoveryStructure.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jPanelRecoveryStructure.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jPanelRecoveryStructureFocusGained(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel5.setText("Selected File:");

        txFile.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        txtFNroClusters.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        jLabel2.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel2.setText("Maximum Number of Methods by Level: ");

        txtFNroNivel.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel1.setText("Maximum Depth of the Call Tree: ");

        jLabel4.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel4.setText("Minimum Ratio:");

        txtFNroCoberturaChamadas.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));

        jLabel6.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel6.setText("%");

        btnGetStructure.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnGetStructure.setText("Execute");
        btnGetStructure.setMaximumSize(new java.awt.Dimension(67, 23));
        btnGetStructure.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGetStructureActionPerformed(evt);
            }
        });

        jCheckBoxCompressor.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jCheckBoxCompressor.setSelected(true);
        jCheckBoxCompressor.setText("Without compressing the tree.");

        javax.swing.GroupLayout jPanelRecoveryStructureLayout = new javax.swing.GroupLayout(jPanelRecoveryStructure);
        jPanelRecoveryStructure.setLayout(jPanelRecoveryStructureLayout);
        jPanelRecoveryStructureLayout.setHorizontalGroup(
            jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxCompressor)
                    .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFNroNivel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFNroCoberturaChamadas, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6))
                    .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFNroClusters, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(btnGetStructure, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txFile, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanelRecoveryStructureLayout.setVerticalGroup(
            jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRecoveryStructureLayout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtFNroNivel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtFNroClusters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelRecoveryStructureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtFNroCoberturaChamadas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(30, 30, 30)
                .addComponent(jCheckBoxCompressor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnGetStructure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(16, 16, 16))
        );

        jTabbedPane1.addTab("Architectural View", jPanelRecoveryStructure);

        jTxtSequence1.setEditable(false);
        jTxtSequence1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        jLabel11.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel11.setText("Trace 1:");

        jLabel12.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jLabel12.setText("Trace 2:");

        jTxtSequence2.setEditable(false);
        jTxtSequence2.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));

        btnAlign.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnAlign.setText("Align");
        btnAlign.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAlignActionPerformed(evt);
            }
        });

        jCheckBoxSeq1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jCheckBoxSeq1.setText("Insert");
        jCheckBoxSeq1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxSeq1ActionPerformed(evt);
            }
        });

        jCheckBoxSeq2.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        jCheckBoxSeq2.setText("Insert");

        btnViewAlignment.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11));
        btnViewAlignment.setText("View Alignment");
        btnViewAlignment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewAlignmentActionPerformed(evt);
            }
        });

        jBtnColapsedTree.setText("Colapsed Tree");
        jBtnColapsedTree.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnColapsedTreeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jBtnColapsedTree)
                        .addGap(18, 18, 18)
                        .addComponent(btnViewAlignment))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxtSequence1, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxtSequence2, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jCheckBoxSeq2)
                            .addComponent(jCheckBoxSeq1))
                        .addGap(33, 33, 33))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(btnAlign)
                        .addGap(24, 24, 24))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtSequence1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(jCheckBoxSeq1))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtSequence2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jCheckBoxSeq2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAlign)
                    .addComponent(btnViewAlignment)
                    .addComponent(jBtnColapsedTree))
                .addGap(21, 21, 21))
        );

        jTabbedPane1.addTab("Sequence Alignment", jPanel1);

        jPanelText.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Messages ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Microsoft Sans Serif", 0, 11))); // NOI18N
        jPanelText.setMaximumSize(new java.awt.Dimension(510, 99999));
        jPanelText.setMinimumSize(new java.awt.Dimension(510, 298));
        jPanelText.setPreferredSize(new java.awt.Dimension(510, 320));

        jScrollPane1.setViewportView(jTextPaneMessages);

        javax.swing.GroupLayout jPanelTextLayout = new javax.swing.GroupLayout(jPanelText);
        jPanelText.setLayout(jPanelTextLayout);
        jPanelTextLayout.setHorizontalGroup(
            jPanelTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
        );
        jPanelTextLayout.setVerticalGroup(
            jPanelTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
        );

        jPanelProgress.setMaximumSize(new java.awt.Dimension(368, 14));
        jPanelProgress.setMinimumSize(new java.awt.Dimension(100, 14));
        jPanelProgress.setPreferredSize(new java.awt.Dimension(368, 14));

        labelProgressTask.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));

        javax.swing.GroupLayout jPanelProgressLayout = new javax.swing.GroupLayout(jPanelProgress);
        jPanelProgress.setLayout(jPanelProgressLayout);
        jPanelProgressLayout.setHorizontalGroup(
            jPanelProgressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelProgressLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelProgressTask, javax.swing.GroupLayout.PREFERRED_SIZE, 479, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanelProgressLayout.setVerticalGroup(
            jPanelProgressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelProgressLayout.createSequentialGroup()
                .addComponent(labelProgressTask, javax.swing.GroupLayout.DEFAULT_SIZE, 3, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
        jPanel.setLayout(jPanelLayout);
        jPanelLayout.setHorizontalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLayout.createSequentialGroup()
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 507, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanelRepository, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
                    .addComponent(jPanelProgress, javax.swing.GroupLayout.PREFERRED_SIZE, 509, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanelLayout.setVerticalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelRepository, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelText, javax.swing.GroupLayout.PREFERRED_SIZE, 236, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelProgress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );

        jPanelMeadle.add(jPanel, "card2");

        getContentPane().add(jPanelMeadle);

        jPnlEast.setPreferredSize(new java.awt.Dimension(230, 509));

        jPanelGSP.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Sequential Patterns ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Microsoft Sans Serif", 0, 11))); // NOI18N

        javax.swing.GroupLayout jPanelGSPLayout = new javax.swing.GroupLayout(jPanelGSP);
        jPanelGSP.setLayout(jPanelGSPLayout);
        jPanelGSPLayout.setHorizontalGroup(
            jPanelGSPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneGSP, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
        );
        jPanelGSPLayout.setVerticalGroup(
            jPanelGSPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneGSP, javax.swing.GroupLayout.DEFAULT_SIZE, 591, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPnlEastLayout = new javax.swing.GroupLayout(jPnlEast);
        jPnlEast.setLayout(jPnlEastLayout);
        jPnlEastLayout.setHorizontalGroup(
            jPnlEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelGSP, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPnlEastLayout.setVerticalGroup(
            jPnlEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelGSP, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        getContentPane().add(jPnlEast);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
           if(jtree != null){
               Dimension d = jPnlRepository.getSize();
               jScrollPaneTree.setSize(d.width-7, d.height-30);
               jScrollPaneTree.setViewportView(jtree);
               jPnlRepository.add(jScrollPaneTree);
               jPnlRepository.setVisible(true);
           }
    }//GEN-LAST:event_formComponentResized

    private void repaintComponents(){
        Graphics g = jPanelText.getGraphics();
        jPanelText.paint(g);
        Graphics g2 = jPnlRepository.getGraphics();
        jPnlRepository.paint(g2);
        Graphics g3 = jPanelProgress.getGraphics();
        jPanelProgress.paint(g3);
        Graphics gsp = jPanelGSP.getGraphics();
        jPanelGSP.paint(gsp);
    }

    private void insertMessages(Controller controller) {
        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+controller.getMessages().toString());
        controller.initialiseMessages();
    }

    public final void insertTraceTree() {
        File[] files = new File(strCurrentPath).listFiles();
        system = getSO();
        if(files != null){
            jtree = TraceTree.start(files);
            jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            jtree.addTreeSelectionListener(this);
            jScrollPaneTree.setViewportView(jtree);
            jPnlRepository.add(jScrollPaneTree);
            jPnlRepository.setVisible(true);
        }else this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+"It was not possible to generate the tree of traces to the path: "+strCurrentFilePath);
    }

    private void btnBuildTreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuildTreeActionPerformed
                jTextPaneMessages.setText("");
                repaintComponents();
                /* Getting the chosen radio */
                requiredMethod = " - Motivo: Prefixo";
                int option = 2;//for enabled radioPrefix
                if(this.radioEqual.isSelected()){ option = 1; requiredMethod = " - Motivo: Equal";}
                else if(this.radioSuffix.isSelected()){ option = 3; requiredMethod = " - Motivo: Suffix";}
                else if(this.radioExtremity.isSelected()) {option = 4; requiredMethod = " - Motivo: Any";}
                else if(this.radioBtnA_C.isSelected()) {option = 5; requiredMethod = " - Motivo: a..c";}
                /* Gets others parameters */
                size = 1;
                double support = 0.05;
                if(!this.txtFSize.getText().equals("")) size = Integer.parseInt(this.txtFSize.getText());
                if(!this.txtFieldSuporte.getText().equals("")) support = Double.parseDouble(this.txtFieldSuporte.getText())/100;
                if(!this.strCurrentPathSelected.equals("")){
                    try {
                        labelProgressTask.setText("Executando algoritmo GSP ...");
                        repaintComponents();
                        Tree sequenceTreeGSP = new Tree();
                        File dataMining = null;
                        if(new File(strCurrentPathSelected).isFile()) dataMining = new File(strCurrentPathSelected);
                        else dataMining = new File(strCurrentPathSelected+system+"data.trace");
                        if(dataMining.exists()){
                            jtreeGSP = sequenceTreeGSP.start(dataMining.getAbsolutePath(), option, size, support, requiredMethod, jPanelProgress, labelProgressTask);
                            sequenceTree = sequenceTreeGSP.getTree();
                            if(sequenceTreeGSP.getIsOk()){
                                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                                labelProgressTask.setText("Construindo árvore das sequências ... finalizado.");
                                insertSequenceTree();
                                repaintComponents();
                            }else this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n>> Nenhum candidato encontrado para o suporte "+(support*100)+"%.\n");
                        }else this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n Arquivo não encontrado.");
                        
                    } catch (ClassNotFoundException ex) {
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    } catch (InstantiationException ex) {
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    } catch (IllegalAccessException ex) {
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    } catch (UnsupportedLookAndFeelException ex) {
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    } catch(Exception ex){
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    } catch(Error ex){
                         this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ ex);
                    }
         }
}//GEN-LAST:event_btnBuildTreeActionPerformed

private void insertSequenceTree() {        
     jtreeGSP.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     jtreeGSP.addTreeSelectionListener(this);
     jScrollPaneGSP.setViewportView(jtreeGSP);
     jPanelGSP.add(jScrollPaneGSP);
     jPanelGSP.setVisible(true);
}

public void valueChanged(TreeSelectionEvent e) {
       DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                           jtree.getLastSelectedPathComponent();
       isValidTrace(node);
    }


    private void isValidTrace(DefaultMutableTreeNode selectedNode){
        if(selectedNode != null){
           txtFieldSelectedTrace.setText("");
           File[] files = new File(strCurrentPath).listFiles();
           if(files != null){
               String path ="";
               for(File file : files){
                   if(file.getName().equals(selectedNode.toString())){
                       strCurrentPathSelected = file.getAbsolutePath();
                       txtFieldSelectedTrace.setText(file.getName());
                       txtFieldSelectedTraceCompressor.setText(file.getName());
                       jTxtFeature.setText(file.getName());
                       if(!jCheckBoxSeq1.isSelected()) jTxtSequence1.setText(file.getName());
                       if(!jCheckBoxSeq2.isSelected()) jTxtSequence2.setText(file.getName());
                       break;
                   }
                   else if(file.getName().equals(selectedNode.getPath()[1].toString())){
                       path = file.getAbsolutePath()+system+selectedNode.getPath()[2].toString();
                       for(int i=3; i<selectedNode.getPath().length; i++){
                           path = path + system+selectedNode.getPath()[i].toString();
                       }
                       strCurrentPathSelected = path;
                       txtFieldSelectedTrace.setText(path);
                       txtFieldSelectedTraceCompressor.setText(path);
                       jTxtFeature.setText(path);
                       txFile.setText(path);
                       if(!jCheckBoxSeq1.isSelected()) jTxtSequence1.setText(path);
                       if(!jCheckBoxSeq2.isSelected()) jTxtSequence2.setText(path);
                       break;
                 }
               }               
           }
      }
    }


    private void btnExecutePreProcessingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExecutePreProcessingActionPerformed
             jTextPaneMessages.setText("");
             if(!txtFieldSelectedTraceCompressor.getText().endsWith(".info")){
                String dir = getSO();
                String step = "Passo 1";
                try{
                    controller = new Controller(this.txtMetrics.getText(), dir);
                    strCurrentPathSelected = controller.alterTraceRepository(strCurrentPathSelected);
                    File newFilePathStep = null;
                    jTextPaneMessages.setText("");
                    repaintComponents();
                    //jListFiles.setModel(new DefaultListModel());
                    if((this.jComboBoxStep1.getSelectedIndex() == 1 || this.jComboBoxStep2.getSelectedIndex() == 1 || this.jComboBoxStep3.getSelectedIndex() == 2) && txtMetrics.getText().equals("")){
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText() + LOG.compressorInvalidParameters());
                    }else{
                       //controller.setStep1(this.jComboBoxStep1.getSelectedIndex(), this.strCurrentPathSelected, jPanelProgress, labelProgressTask);
                       //Thread th = new Thread(controller);
                       final SwingWorker worker = new SwingWorker() {
                        public Object construct() {
                            try {
                                return doStep1();
                            } catch (IOException ex) {
                                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            return null;
                        }
                        public void finished() {
                            insertMessages(controller);
                            labelProgressTask.setText(LOG.getMessageStep2() + jComboBoxStep2.getSelectedItem());
                            repaintComponents();
                            insertTraceTree();
                            labelProgressTask.setText(LOG.updatedRepository());
                        }
                       };
                        worker.start();
                        //newFilePathStep = controller.step1(this.jComboBoxStep1.getSelectedIndex(), this.strCurrentPathSelected, jPanelProgress, labelProgressTask);
//                        insertMessages(controller);
//                        labelProgressTask.setText("Executando o Passo 2:"+this.jComboBoxStep2.getSelectedItem());
//                        repaintComponents();
                        if(this.jComboBoxStep2.getSelectedIndex() > 0){
                            step = "Passo 2";
                            final SwingWorker worker2 = new SwingWorker() {
                                public Object construct() {
                                    insertMessages(controller);
                                    labelProgressTask.setText(LOG.getMessageStep3() + jComboBoxStep3.getSelectedItem());
                                    try {
                                        return doStep2(new File(worker.get().toString()));
                                    } catch (IOException ex) {
                                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                                    }
                                    return null;
                                }
                                public void finished() {
                                    repaintComponents();
                                    insertTraceTree();
                                    labelProgressTask.setText(LOG.updatedRepository());
                                }
                            };
                            worker2.start();
                            //newFilePathStep = controller.step2(this.jComboBoxStep2.getSelectedIndex(), newFilePathStep, jPanelProgress, labelProgressTask);
                            //insertMessages(controller);
                            if(this.jComboBoxStep3.getSelectedIndex() > 0){
                                step = "Passo 3";
                                SwingWorker worker3 = new SwingWorker() {
                                public Object construct() {
                                    try {
                                        return doStep3(new File(worker2.get().toString()));
                                    } catch (IOException ex) {
                                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                                    }
                                    return null;
                                }
                                public void finished() {
                                    insertMessages(controller);
                                    labelProgressTask.setText(LOG.updatingRepository());
                                    repaintComponents();
                                    insertTraceTree();
                                    labelProgressTask.setText(LOG.updatedRepository());
                                }
                                };
                                worker3.start();
//                                labelProgressTask.setText("Executando o Passo 3:"+this.jComboBoxStep3.getSelectedItem());
//                                repaintComponents();
                                //newFilePathStep = controller.step3(this.jComboBoxStep3.getSelectedIndex(), newFilePathStep, jPanelProgress, labelProgressTask);
//                                insertMessages(controller);
                            }
                        }
                        
                    }
                }catch(NumberFormatException e){
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText() + LOG.numberFormatException() + e.toString());
                }catch(IOException e){
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+e.toString());
                } catch(Exception e){
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+ LOG.errorOcurred(step) + e.toString());
                } catch(Error error){
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n "+error.toString() + " "+strCurrentPathSelected);
                }
                }
}//GEN-LAST:event_btnExecutePreProcessingActionPerformed

    private void jComboBoxStep2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxStep2ItemStateChanged
                if(this.jComboBoxStep2.getSelectedIndex() > 0){
                    this.jComboBoxStep3.setVisible(true);
                    jLabel9.setVisible(true);
                    this.jLabel15.setVisible(true);
                    this.txtMetrics.setVisible(true);
                } else{
                    this.jComboBoxStep3.setVisible(false);
                    jLabel9.setVisible(false);
                    this.jLabel15.setVisible(false);
                    this.txtMetrics.setVisible(false);
                }
}//GEN-LAST:event_jComboBoxStep2ItemStateChanged

    public Object doStep1() throws IOException {
        return controller.step1(jComboBoxStep1.getSelectedIndex(), strCurrentPathSelected, jPanelProgress, labelProgressTask);
    }

    public Object doStep2(File newFilePathStep) throws IOException{
        return controller.step2(this.jComboBoxStep2.getSelectedIndex(), newFilePathStep, jPanelProgress, labelProgressTask);
    }

    public Object doStep3(File newFilePathStep) throws IOException{
        return controller.step3(jComboBoxStep3.getSelectedIndex(), newFilePathStep, jPanelProgress, labelProgressTask);
    }

    private void jButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonActionPerformed
                JFileChooser fc;
                if(strCurrentPath.compareTo("")!=0){
                    fc = new JFileChooser(strCurrentPath);
                }else{
                    fc = new JFileChooser();
                }
                fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int intReturn = fc.showOpenDialog(txtFPath);
                if(intReturn == JFileChooser.APPROVE_OPTION){
                    strCurrentPath=fc.getSelectedFile().getAbsolutePath();
                    txtFPath.setText(strCurrentPath);
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch(Exception ex){
                        this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                    }
                    insertTraceTree();
                }
}//GEN-LAST:event_jButtonActionPerformed

    private void btnDeleteDirectoriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteDirectoriesActionPerformed
        Controller.removeTrace(strCurrentPathSelected);
        jTextPaneMessages.setText("");
        insertTraceTree();
        strCurrentPathSelected="";
        txtFieldSelectedTrace.setText("");
}//GEN-LAST:event_btnDeleteDirectoriesActionPerformed

    private String getSO(){
        String dir = "";
        if(!strCurrentPath.startsWith("/")) dir = "\\";
        else dir = "/";
        return dir;
    }

    private void jBtnSaveSequenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSaveSequenceActionPerformed
        labelProgressTask.setText("Salvando árvore ...");
        jTextPaneMessages.setText("");
        repaintComponents();
        String dir = getSO();
        String support = "5";
        String motive = "";
        if(!txtFieldSuporte.getText().equals("")) support = txtFieldSuporte.getText();
        if(!requiredMethod.equals("")){
            String[] method = requiredMethod.split(" ");
            motive = method[method.length-1];
        }
        try{
            SaveJTree.saveModel(sequenceTree, null, new File(strCurrentPathSelected), dir, support, motive, size);
            insertTraceTree();
            labelProgressTask.setText("Salvando árvore ... finalizado.");
        }catch(IOException e){
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+e.toString());
        }        
    }//GEN-LAST:event_jBtnSaveSequenceActionPerformed

    private void jButtonCarryTreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCarryTreeActionPerformed
        labelProgressTask.setText("Recuperando árvore ...");
        jTextPaneMessages.setText("");
        repaintComponents();
        try {
            DefaultMutableTreeNode model = SaveJTree.loadModel(new File(strCurrentPathSelected));
            viewer.main.tree.Tree treeToMemory = new viewer.main.tree.Tree();
            jtreeGSP = treeToMemory.setTree(model);
            insertSequenceTree();
            labelProgressTask.setText("Árvore recuperada.");
        } catch (FileNotFoundException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        } catch (IOException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        } catch (ClassNotFoundException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        }
}//GEN-LAST:event_jButtonCarryTreeActionPerformed

    private void btnGetStructureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetStructureActionPerformed
        jTextPaneMessages.setText("");
        labelProgressTask.setText(LOG.recoveringTreeView());
        repaintComponents();
        File file = new File(strCurrentPathSelected);
        //String dir = getSO();
        file = getFile(file);
             if((tree == null )|| !tree.getFilePath().equals(file.getAbsolutePath()) || (jCheckBoxCompressor.isSelected()!=changed)){
            tree = new builder.tree.Tree(file.getAbsolutePath());
            try {
                tree.generateTree();
                changed = jCheckBoxCompressor.isSelected();
                if(!jCheckBoxCompressor.isSelected() && tree.getTree() != null){
                    CompressTree compressor = new CompressTree(tree.getTree());
                    compressor.applyCompressTree();
                }
            } catch (IOException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (NullPointerException ex){
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch(ArrayIndexOutOfBoundsException ex){
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (Error ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            }

            }
            if(tree.getTree() != null && !txtFNroClusters.getText().equals("") && !txtFNroCoberturaChamadas.getText().equals("")
                        && !txtFNroNivel.getText().equals("")){
                try {
                    TreeDisplay treeDisplay = new TreeDisplay(null);
                    boolean updated = treeDisplay.begin(tree, txtFNroClusters.getText(), txtFNroCoberturaChamadas.getText(), txtFNroNivel.getText(), strCurrentPathSelected, getSO());
                    if(updated){
                        insertTraceTree();
                    }
                } catch (ClassNotFoundException ex) {
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                } catch (InstantiationException ex) {
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                } catch (IllegalAccessException ex) {
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                } catch (UnsupportedLookAndFeelException ex) {
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                }catch (Error ex) {
                    this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
                }
            }
        labelProgressTask.setText(LOG.recoveredTreeView());
}//GEN-LAST:event_btnGetStructureActionPerformed


    private File getFile(File file) {
        if(file.isDirectory()) return getFile(file.listFiles()[0]);
        return file;
    }


    private void jPanelRecoveryStructureFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanelRecoveryStructureFocusGained
        tree = new builder.tree.Tree();
    }//GEN-LAST:event_jPanelRecoveryStructureFocusGained

    private void jButtonFeatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFeatureActionPerformed
        jTextPaneMessages.setText("");
        labelProgressTask.setText(LOG.recoveringFunctionalities());
        repaintComponents();
        Controller control = null;
        if(new File(strCurrentPathSelected).isFile()) control = new Controller(strCurrentPathSelected);
        else control = new Controller(strCurrentPathSelected+getSO()+"trace.mark.txt");
        try {
            control.readFeatureMarkFile();
            control.splitFeatures();
            insertTraceTree();
            labelProgressTask.setText(LOG.recoveredFunctionalities());
        } catch (FileNotFoundException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        } catch (IOException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        } catch (SecurityException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        } catch (Error ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        }        
    }//GEN-LAST:event_jButtonFeatureActionPerformed

    private void jComboBoxStep3ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxStep3ItemStateChanged
   
    }//GEN-LAST:event_jComboBoxStep3ItemStateChanged

    private void jComboBoxStep1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStep1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxStep1ActionPerformed

    private void jComboBoxStep1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxStep1ItemStateChanged
        if(jComboBoxStep1.getSelectedIndex() == 1){
            jLabel15.setVisible(true);
            txtMetrics.setVisible(true);
        }else if(jComboBoxStep1.getSelectedIndex() == 0 && jComboBoxStep2.getSelectedIndex()!= 1 && jComboBoxStep3.getSelectedIndex() != 2){
            this.jLabel15.setVisible(false);
            this.txtMetrics.setVisible(false);
        }
    }//GEN-LAST:event_jComboBoxStep1ItemStateChanged

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
        
    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void btnAlignActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlignActionPerformed
        align = false;
        jTextPaneMessages.setText("");
        rootSequence = new File(jTxtSequence1.getText());
        newDirectory = rootSequence.getParentFile().getParentFile().getParentFile().getParentFile().getPath()+"\\AlignmentTemporaryFiles";
            if((new File(newDirectory)).exists()){
            try{
                Controller.removeTrace(newDirectory);
            }catch(SecurityException ex){
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            }
        }
        String message = null;
        try {
            message = NeedlemanWunsch.run(jTxtSequence1.getText(), jTxtSequence2.getText(), newDirectory);
        } catch (IOException ex) {
            this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
        }
        jTextPaneMessages.setText(message);
        align = true;
    }//GEN-LAST:event_btnAlignActionPerformed

    private void jCheckBoxSeq1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSeq1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBoxSeq1ActionPerformed

    private void btnViewAlignmentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewAlignmentActionPerformed
        this.jTextPaneMessages.setText("");
        if(align){
            AlignmentTree generateTree = new AlignmentTree();
            File file = new File(jTxtSequence1.getText());
            String[] parameter = file.getParent().split("-");
            String alignmentPath = "";
            for(String attribute : parameter){
                alignmentPath = alignmentPath +"-"+ attribute;
            }
            try {
                generateTree.startAlignmentTree(rootSequence.getParentFile().getParentFile().getParentFile().getParentFile().getPath() + "\\AlignmentTemporaryFiles", alignmentPath);
            } catch (ClassNotFoundException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (InstantiationException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (IllegalAccessException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (UnsupportedLookAndFeelException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (FileNotFoundException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (IOException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            }
        }
    }//GEN-LAST:event_btnViewAlignmentActionPerformed

    private void jBtnColapsedTreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnColapsedTreeActionPerformed
            if(align){
                AlignmentTree generateTree = new AlignmentTree();
            try {
                generateTree.generateAlignmentTree(rootSequence.getParentFile().getParentFile().getParentFile().getParentFile().getPath() + "\\AlignmentTemporaryFiles");
                ColapsedTrees colapsedTrees = new ColapsedTrees(generateTree.getDefaultMutableTreeNode(), jTxtSequence1.getText(), jTxtSequence2.getText());
                colapsedTrees.colapseTraces();
            } catch (ClassNotFoundException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (InstantiationException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (IllegalAccessException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (UnsupportedLookAndFeelException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (FileNotFoundException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            } catch (IOException ex) {
                this.jTextPaneMessages.setText(jTextPaneMessages.getText()+"\n"+ex.toString());
            }
        }
    }//GEN-LAST:event_jBtnColapsedTreeActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Main frame = new Main();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }

    String newDirectory = null;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAlign;
    private javax.swing.JButton btnBuildTree;
    private javax.swing.JButton btnDeleteDirectories;
    private javax.swing.JButton btnExecutePreProcessing;
    private javax.swing.JButton btnGetStructure;
    private javax.swing.JButton btnViewAlignment;
    private javax.swing.ButtonGroup buttonGroup;
    private javax.swing.JButton jBtnColapsedTree;
    private javax.swing.JButton jBtnSaveSequence;
    private javax.swing.JButton jButton;
    private javax.swing.JButton jButtonCarryTree;
    private javax.swing.JButton jButtonFeature;
    private javax.swing.JCheckBox jCheckBoxCompressor;
    private javax.swing.JCheckBox jCheckBoxSeq1;
    private javax.swing.JCheckBox jCheckBoxSeq2;
    private javax.swing.JComboBox jComboBoxStep1;
    private javax.swing.JComboBox jComboBoxStep2;
    private javax.swing.JComboBox jComboBoxStep3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanelCenter;
    private javax.swing.JPanel jPanelCompressors;
    private javax.swing.JPanel jPanelDataMining;
    private javax.swing.JPanel jPanelEast;
    private javax.swing.JPanel jPanelFeature_North;
    private javax.swing.JPanel jPanelFeature_South;
    private javax.swing.JPanel jPanelFeatures;
    private javax.swing.JPanel jPanelGSP;
    private javax.swing.JPanel jPanelMeadle;
    private javax.swing.JPanel jPanelNorth;
    private javax.swing.JPanel jPanelNorthCompressor;
    private javax.swing.JPanel jPanelProgress;
    private javax.swing.JPanel jPanelRecoveryStructure;
    private javax.swing.JPanel jPanelRepository;
    private javax.swing.JPanel jPanelText;
    private javax.swing.JPanel jPnlEast;
    private javax.swing.JPanel jPnlRepository;
    private javax.swing.JPanel jPnlWeast;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPaneGSP;
    private javax.swing.JScrollPane jScrollPaneTree;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextPane jTextPaneMessages;
    private javax.swing.JTextField jTxtFeature;
    private javax.swing.JTextField jTxtSequence1;
    private javax.swing.JTextField jTxtSequence2;
    private javax.swing.JLabel labelProgressTask;
    private javax.swing.JRadioButton radioBtnA_C;
    private javax.swing.JRadioButton radioEqual;
    private javax.swing.JRadioButton radioExtremity;
    private javax.swing.JRadioButton radioPrefix;
    private javax.swing.JRadioButton radioSuffix;
    private javax.swing.JTextField txFile;
    private javax.swing.JTextField txtFNroClusters;
    private javax.swing.JTextField txtFNroCoberturaChamadas;
    private javax.swing.JTextField txtFNroNivel;
    private javax.swing.JTextField txtFPath;
    private javax.swing.JTextField txtFSize;
    private javax.swing.JTextField txtFieldSelectedTrace;
    private javax.swing.JTextField txtFieldSelectedTraceCompressor;
    private javax.swing.JTextField txtFieldSuporte;
    private javax.swing.JTextField txtMetrics;
    // End of variables declaration//GEN-END:variables


}
